// 引入request
import request from '../util/request.js';

const OrderRequest = {
    BASE_URL : "http://localhost:8085/pro",
    // 请求过程在这里开发，不在.vue文件中开发
    /**
     * 多条件分页查询order列表
     * @param order
     * @param callBack
     */
    loadOrder(order, callBack){
        // 拼接url  /sys/queryByPage?xxx
        let url = this.BASE_URL + "/order/queryByPage";
        // 调用request进行请求  http://lcation
        request.get(url,order,callBack);
    },
    /**
     * 新增工单的API
     * @param order
     * @param callBack
     */
    addOrder(order,callBack){
        let url = this.BASE_URL + "/order/saveOrder"
        request.post(url,order,callBack);
    },
    /**
     * 通过id加载工单信息的API
     * @param woId
     * @param callBack
     */
    getById(woId,callBack){
        let url = this.BASE_URL + "/order/queryById?woId=" + woId;
        // let url = this.BASE_URL + "/order/queryById?woId=1";
        request.get(url,null,callBack);
    }
    ,
    /**
     * 修改工单信息的API
     * @param order
     * @param callBack
     */
    updateOrder(order,callBack){
        let url = this.BASE_URL + "/order/updateOrder";
        request.post(url,order,callBack);
    },
    /**
     *  删除工单的API
     * @param woId
     * @param callBack
     */
    deleteOrder(woId,callBack){
        request.get(this.BASE_URL + "/order/delete?woId=" + woId,null,callBack);
    },
    /**
     * 批量删除工单的API
     * @param woIds
     * @param callBack
     */
    deleteOrders(woIds,callBack){
        console.log(woIds)
        let url = this.BASE_URL + "/order/deletes?woIds="+woIds;
        request.get(url,null,callBack);
    },
    getOrderList(callback){
        request.get(this.BASE_URL + "/order/queryAll", {},callback);
    },
    getRulesEncoding(param, callback){
        request.get( "http://localhost:8080/sys/rules/query", param, callback);
    }
}
// 导出我们申明的orderRequest对象
export default OrderRequest;